usrname = 'maxie'
passwd = '123'
count = 1

while True: # 这里可以用for循环改写一下
    usrname_input = input('username: ')
    passwd_input = input('password: ')
    
    if usrname_input == usrname and passwd_input == passwd:
        print('login success')
        break
    elif count < 3: # 这里的判断条件可以提到while条件里面
        print('用户名或密码错误!')
        print('please retry...')
        count += 1
    else:
        print(f'用户名或密码错误{count}次!退出程序 ')
        break
    
